package com.baoyouqun.domain.VO;

import lombok.Data;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Objects;

/**
 * 豹友详情VO（页面展示+Excel导出通用）
 */
@Data
public class LeopardFriendDetailVO implements Serializable {
    private static final long serialVersionUID = 1L;
    private static final DateTimeFormatter DT_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

    // 基础信息（User表）
    private String userId;
    private String name = "未填写";
    private String sex = "未知";
    private String cellphone = "未填写";
    private String industry = "未填写";
    private String company = "未填写";
    private String job = "未填写";
    private String education = "未填写";
    private String region = "未填写";
    private LocalDateTime lastLoginTime;
    private Boolean disEnable = false;
    private Boolean logout = false;

    // 资源信息（UserResource表）
    private String ownResource = "无";
    private String needResource = "无";

    // 统计信息（Post/Friend表）
    private Integer postCount = 0;
    private Integer friendCount = 0;

    // VIP信息（UserVipTime+VipLevel表）
    private LocalDateTime vipEndTime;
    private Integer remainAccessDays = 0;
    private String vipLevelName = "临时会员";

    // 衍生字段（动态计算，前端直接用）
    public String getStatus() {
        if (Objects.isNull(disEnable) || Objects.isNull(logout)) {
            return "异常状态";
        }
        if (!disEnable && !logout) {
            return "正常使用";
        }
        return disEnable ? "禁用" : "已注销";
    }

    public String getLastLoginTimeDesc() {
        return Objects.nonNull(lastLoginTime) ? lastLoginTime.format(DT_FORMATTER) : "未登录";
    }

    public String getRemainAccessDaysDesc() {
        return remainAccessDays > 0 ? remainAccessDays + "天" : "已过期/非会员";
    }
}